
/*
 * @Description:String 测试类
 * 
 * @Author: rendc
 * 
 * @Date: 2025-08-08 09:06:16
 * 
 * @LastEditors: rendc
 * 
 * @LastEditTime: 2025-08-08 10:23:50
 */

public class TestString extends Object {

  public static void main(String[] args) {
    String s1 = "123";
    String s2 = new String("123");
    // String s11 = "你好吗";
    String s13 = "abc";
    String s12 = new String("abc");
    // 常量池
    String s3 = "123";
    String s4 = new String("123").intern();
    // char[] char1 = s11.toCharArray();
    // System.out.println(Arrays.toString(char1));
    // s1.split(s4, 1);
    // 截取字符串的最后一位
    // String newS11 = s11.substring(1);
    // System.out.println("s11:" + s11);
    // System.out.println("newS11:" + newS11);
    // String newS11 = s11.substring(1, 2);
    // System.out.println("s11:" + s11);
    // System.out.println("newS11:" + newS11);
    String s11 = "你好吗";
    // String newS11 = s11.replace('走', '!');
    // System.out.println("s11:" + s11);
    // System.out.println("newS11:" + newS11);
    String newS11 = s11.replace("你好", "大家好");
    System.out.println("s11:" + s11);
    // Character
    System.out.println("newS11:" + newS11);
    int index = s11.indexOf("你");
    System.out.println(index);
    // System.out.println(" s11.charAt(0):" + s11.charAt(0));
    // System.out.println(" s11.charAt(1):" + s11.charAt(1));
    // System.out.println(" s11.charAt(2):" + s11.charAt(2));
    // System.out.println(" s1.charAt(-1):" + s1.charAt(-1));
    // System.out.println(" s1.charAt(3):" + s1.charAt(3));
    // s1 == s2; // false
    // System.out.println("s1 == s2:" + (s1 == s2));
    // System.out.println("s1.equals(s2):" + s1.equals(s2));
    // System.out.println("s11 == s12:" + (s11 == s12));
    // System.out.println("s11 == s13:" + (s11 == s13));
    // System.out.println("s11.equals(s12):" + s11.equals(s12));
    // s1 == s3;
    // s2 == s3; // false
    // s1 == s3 == s4;
    // System.out.println("s1.length():" + s1.length());// 3
    // System.out.println("s2.length():" + s2.length());// 3

  }
}